'use strict';

const Service = require('egg').Service;

class HomeService extends Service {
    //添加
    async put(title,create_time,status,import_num,author,num) {
        await this.app.mysql.query('insert into list (title,create_time,status,import_num,author,num) values (?,?,?,?,?,?)',[title,create_time,status,import_num,author,num])
    }
    //修改
    async update(title,create_time,status,import_num,id){
        await this.app.mysql.query('update list set title=?,create_time=?,status=?,import_num=? where id=?',[title,create_time,status,import_num,id])
    }
    //删除
    async del(id){
        await this.app.mysql.query('delete from list where id=?',[id])
    }
    //查询
    async booklist(start,count){
        return await this.app.mysql.query(`select * from list limit ${start},${count}`)
    }
    //查询总条数
    async total(){
        return await this.app.mysql.query('select count(*) from list');
    }
}

module.exports = HomeService;
